package com.lds.erp.util;

import org.springframework.stereotype.Component;

import com.lds.erp.configuration.ConfigProperty;
import com.qiniu.util.Auth;

/**
 * Author: Time: 2016-01-28 15:00 Copyright (C) 2016
 */
@Component
public class Uptoken {

	// 简单上传，使用默认策略
	public static QiNiuTokenVO getUpToken() {
		ConfigProperty configProperty = SpringContextUtils.getBean(ConfigProperty.class);
		String ACCESS_KEY = configProperty.getQiniuAccessKey();
		String SECRET_KEY = configProperty.getQiniuSecretKey();
		String BUCKET = configProperty.getQiniuBucket();
		Auth auth = Auth.create(ACCESS_KEY, SECRET_KEY);

		QiNiuTokenVO vo = new QiNiuTokenVO();
		vo.setToken(auth.uploadToken(BUCKET,null,360000,null));
		vo.setImageDomain(configProperty.getQiniuImageDomain());
		return vo;
	}
}
